Split Object, Splits Collection Example

The following example adds a new fixed split to a DataGrid control. To try this example, add a Data control and a DataGrid control to the form of a new Standard EXE project. Set the DatabaseName and RecordSource properties of the Data control to "BIBLIO.MDB" and "AUTHORS". Paste the following code into the General Declarations section of the form:

Private Sub Form_Load()
   ' Before modifying the grid's properties, make sure 
   ' the grid is initialized by refreshing the Data 
   ' control.
   Data1.Refresh

   ' Create an additional splits:
   DataGrid1.Splits.Add 0 ' Create an additional split

   ' Hide all columns in the leftmost split, 
   ' Splits(0), except for columns 0 and 1
   Dim Cols As Columns, C As Column
   Set Cols = DataGrid1.Splits(0).Columns
   For Each C In Cols
      C.Visible = False
   Next C
   Cols(0).Visible = True
   Cols(1).Visible = True

   ' Configure Splits(0) to display exactly two 
   ' columns, and disable resizing
   With DataGrid1.Splits(0)
      .SizeMode = dbgNumberOfColumns
      .Size = 2
      .AllowSizing = False
   End With

   ' Usually, if you fix columns 0 and 1 from 
   ' scrolling in a split, you will want to make them 
   ' invisible in other splits:
   Set Cols = DataGrid1.Splits(1).Columns
   Cols(0).Visible = False
   Cols(1).Visible = False

   ' Turn off the record selectors in Split 1:
   DataGrid1.Splits(1).RecordSelectors = False
End Sub